<template>
	<view class="tixian-container">
		<view class="kuang">
			<image class="bj" src="/static/图层 1@3x.png" mode=""></image>
			<view class="nav-bar">
				<view class="nav-left" @click="goBack">
					<uni-icons type="left" size="20" color="#ffffff"></uni-icons>
				</view>
				<text class="title">申请提现</text>
				<view class="nav-right">
					<view class="header-icon">
						<text>⋯</text>
					</view>
					<text class="nav-separator">|</text>
					<view class="header-icon">
						<view class="target-icon"></view>
					</view>
				</view>
			</view>
		</view>
		
		<scroll-view class="content-scroll" scroll-y>
			<view class="scroll-content">
				<!-- 提现表单卡片 -->
				<view class="form-card">
					<view class="form-item">
						<text class="form-label">账户余额</text>
						<text class="form-value red">¥ 1500.00</text>
					</view>
					
					<view class="form-item">
						<text class="form-label">提现金额</text>
						<view class="form-input-wrapper">
							<input class="form-input" v-model="withdrawAmount" type="number" placeholder="请输入提现金额" />
							<text class="form-unit">元</text>
						</view>
					</view>
					
					<view class="form-item">
						<text class="form-label">真实姓名</text>
						<input class="form-input" v-model="realName" placeholder="请输入真实姓名" />
					</view>
					
					<view class="form-item">
						<text class="form-label">请选择银行</text>
						<picker mode="selector" :range="bankList" :value="bankIndex" @change="onBankChange" class="picker-wrapper">
							<view class="picker-input">
								<input class="form-input" :value="selectedBank || '请选择银行'" disabled />
								<image class="arrow-icon" src="/static/车联网服务商家端-04收支明细-01提现_slices/收起箭头小@3x.png" mode="aspectFit"></image>
							</view>
						</picker>
					</view>
					
					<view class="form-item">
						<text class="form-label">请输入银行卡号</text>
						<input class="form-input" v-model="bankCard" type="number" placeholder="请输入银行卡号" />
					</view>
					
					<text class="privacy-notice">车联网服务平台不会通过任何渠道泄露您的个人信息,请放心填写</text>
					
					<button class="submit-btn" @click="handleSubmit">确认信息并提交</button>
				</view>
				
				<!-- 提现记录卡片 -->
				<view class="record-card">
					<text class="record-title">提现记录</text>
					<view class="record-item" v-for="(item, index) in records" :key="index">
						<view class="record-left">
							<text class="record-desc">商家提现申请</text>
							<text class="record-time">核销时间:{{ item.time }}</text>
						</view>
						<view class="record-right">
							<text class="record-amount" :class="item.status === 'approved' ? 'black' : 'red'">{{ item.amount }}</text>
							<text class="record-status" :class="item.status">{{ item.statusText }}</text>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				withdrawAmount: '',
				realName: '',
				bankCard: '',
				bankList: ['中国工商银行', '中国建设银行', '中国银行', '中国农业银行', '招商银行'],
				bankIndex: 0,
				selectedBank: '',
				records: [
					{
						time: '2022-10-12 11:09',
						amount: '- 100.00',
						status: 'reviewing',
						statusText: '审核中'
					},
					{
						time: '2022-10-12 11:09',
						amount: '- 100.00',
						status: 'approved',
						statusText: '审核通过'
					},
					{
						time: '2022-10-12 11:09',
						amount: '- 100.00',
						status: 'rejected',
						statusText: '审核不通过'
					}
				]
			}
		},
		methods: {
			goBack() {
				uni.navigateBack()
			},
			onBankChange(e) {
				this.bankIndex = e.detail.value
				this.selectedBank = this.bankList[e.detail.value]
			},
			handleSubmit() {
				if (!this.withdrawAmount) {
					uni.showToast({
						title: '请输入提现金额',
						icon: 'none'
					})
					return
				}
				if (!this.realName) {
					uni.showToast({
						title: '请输入真实姓名',
						icon: 'none'
					})
					return
				}
				if (!this.selectedBank) {
					uni.showToast({
						title: '请选择银行',
						icon: 'none'
					})
					return
				}
				if (!this.bankCard) {
					uni.showToast({
						title: '请输入银行卡号',
						icon: 'none'
					})
					return
				}
				
				// 跳转到成功页面
				uni.navigateTo({
					url: '/pages/tixian/tixian-success'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tixian-container {
		min-height: 100vh;
		width: 100%;
		position: relative;
		background-color: #f5f5f5;
	}

	.bj {
		position: absolute;
		z-index: 1;
		width: 750rpx;
		height: 430rpx;
		left: 0;
		top: 0;
	}

	.kuang {
		display: flex;
		flex-direction: column;
		position: relative;
		width: 100%;
		height: 430rpx;
	}

	.nav-bar {
		position: relative;
		z-index: 2;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 30rpx;
		margin-top: 60rpx;
		height: 88rpx;
		box-sizing: border-box;
	}

	.nav-left {
		width: 40rpx;
		height: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: white;
		font-weight: bold;
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
	}

	.nav-right {
		display: flex;
		align-items: center;
	}

	.nav-right > view {
		margin-right: 10rpx;
	}

	.nav-right > view:last-child {
		margin-right: 0;
	}

	.nav-separator {
		color: rgba(255, 255, 255, 0.5);
		font-size: 20rpx;
		margin: 0 8rpx;
	}
	
	.header-icon {
		width: 48rpx;
		height: 48rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		
		text {
			color: #fff;
			font-size: 32rpx;
			line-height: 1;
		}
	}
	
	.target-icon {
		width: 24rpx;
		height: 24rpx;
		border: 2rpx solid #fff;
		border-radius: 50%;
		position: relative;
		
		&::after {
			content: '';
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			width: 8rpx;
			height: 8rpx;
			background: #fff;
			border-radius: 50%;
		}
	}
	
	.content-scroll {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 1;
		overflow-y: auto;
		background: transparent;
	}
	
	.scroll-content {
		padding: 0 20rpx 40rpx 20rpx;
		padding-top: 430rpx;
	}
	
	.form-card {
		position: relative;
		z-index: 2;
		margin: 0;
		margin-top: -210rpx;
		background: #fff;
		border-radius: 30rpx 30rpx 0 0;
		padding: 30rpx;
		padding-bottom: 20rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
		box-sizing: border-box;
	}
	
	.form-item {
		display: flex;
		align-items: center;
		margin-bottom: 30rpx;
		
		.form-label {
			min-width: 200rpx;
			font-size: 28rpx;
			color: #333;
			flex-shrink: 0;
		}
		
		.form-value {
			flex: 1;
			font-size: 28rpx;
			color: #333;
			text-align: right;
			
			&.red {
				color: #ff3b30;
			}
		}
		
		.form-input-wrapper {
			flex: 1;
			display: flex;
			align-items: center;
		}
		
		.form-input {
			flex: 1;
			height: 70rpx;
			background: #f8f8f8;
			border: 1rpx solid #e0e0e0;
			border-radius: 12rpx;
			padding: 0 20rpx;
			font-size: 28rpx;
			color: #333;
		}
		
		.form-input::placeholder {
			color: #999;
		}
		
		.form-unit {
			margin-left: 12rpx;
			font-size: 28rpx;
			color: #333;
		}
	}
	
	.picker-wrapper {
		flex: 1;
		
		.picker-input {
			position: relative;
			display: flex;
			align-items: center;
			
			.arrow-icon {
				position: absolute;
				right: 20rpx;
				width: 24rpx;
				height: 24rpx;
				transform: rotate(180deg);
				z-index: 1;
			}
		}
	}
	
	.privacy-notice {
		display: block;
		font-size: 22rpx;
		color: #999;
		margin-bottom: 40rpx;
		line-height: 1.6;
	}
	
	.submit-btn {
		width: 100%;
		height: 88rpx;
		line-height: 88rpx;
		background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
		color: #fff;
		border: none;
		border-radius: 44rpx;
		font-size: 32rpx;
		font-weight: 500;
		
		&::after {
			border: none;
		}
	}
	
	.record-card {
		background: #fff;
		margin: 0 10rpx;
		border-radius: 16rpx;
		padding: 30rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
		margin-top: 20rpx;
	}
	
	.record-title {
		display: block;
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		margin-bottom: 30rpx;
	}
	
	.record-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx 0;
		border-bottom: 1rpx solid #f0f0f0;
		
		&:last-child {
			border-bottom: none;
		}
	}
	
	.record-left {
		flex: 1;
		display: flex;
		flex-direction: column;
	}
	
	.record-desc {
		font-size: 28rpx;
		color: #333;
		margin-bottom: 10rpx;
	}
	
	.record-time {
		font-size: 24rpx;
		color: #999;
	}
	
	.record-right {
		display: flex;
		flex-direction: column;
		align-items: flex-end;
	}
	
	.record-amount {
		font-size: 32rpx;
		font-weight: 500;
		margin-bottom: 10rpx;
		
		&.red {
			color: #ff3b30;
		}
		
		&.black {
			color: #333;
		}
	}
	
	.record-status {
		font-size: 24rpx;
		color: #999;
		
		&.approved {
			color: #34c759;
		}
		
		&.rejected {
			color: #ff3b30;
		}
	}
</style>

